/*********************************************************************
	Rhapsody	: 7.6
	Login		: Pawel
	Component	: DefaultComponent
	Configuration 	: DefaultConfig
	Model Element	: Lift
//!	Generated Date	: Sun, 27, Nov 2011 
	File Path	: DefaultComponent/DefaultConfig/CargoLiftSystem/Lift.java
*********************************************************************/

package CargoLiftSystem;

//## auto_generated
import java.util.*;
//## auto_generated
import com.ibm.rational.rhapsody.oxf.*;
//## auto_generated
import com.ibm.rational.rhapsody.animation.*;
//## auto_generated
import com.ibm.rational.rhapsody.oxf.states.*;
//## auto_generated
import com.ibm.rational.rhapsody.animcom.animMessages.*;

//----------------------------------------------------------------------------
// CargoLiftSystem/Lift.java                                                                  
//----------------------------------------------------------------------------

//## package CargoLiftSystem 


//## class Lift 
public class Lift implements RiJStateConcept, Animated {
    
    //#[ ignore
    // Instrumentation attributes (Animation)
    private Animate animate;
    
    public static AnimClass animClassLift = new AnimClass("CargoLiftSystem.Lift",false);
    //#]
    
    public Reactive reactive;		//## ignore 
    
    protected boolean currentDirection = true;		//## attribute currentDirection 
    
    protected int currentFloor = 0;		//## attribute currentFloor 
    
    protected int floorsCount = 5;		//## attribute floorsCount 
    
    protected int nextFloor = 0;		//## attribute nextFloor 
    
    protected int requestedFloor = 0;		//## attribute requestedFloor 
    
    protected boolean stop;		//## attribute stop 
    
    protected Alarm itsAlarm;		//## link itsAlarm 
    
    protected AlarmBreakingDetector itsAlarmBreakingDetector;		//## link itsAlarmBreakingDetector 
    
    protected Controller itsController;		//## link itsController 
    
    protected LinkedList<DoorsLock> itsDoorsLock;		//## link itsDoorsLock 
    
    protected Engine itsEngine;		//## link itsEngine 
    
    protected IndoorDisplay itsIndoorDisplay;		//## link itsIndoorDisplay 
    
    protected InnerDoor itsInnerDoor;		//## link itsInnerDoor 
    
    protected Lights itsLights;		//## link itsLights 
    
    protected LocationDetector itsLocationDetector;		//## link itsLocationDetector 
    
    protected ObstacleInDoorDetector itsObstacleInDoorDetector;		//## link itsObstacleInDoorDetector 
    
    protected LinkedList<OuterDoor> itsOuterDoor;		//## link itsOuterDoor 
    
    protected OverloadDetector itsOverloadDetector;		//## link itsOverloadDetector 
    
    protected ScheduleApplication itsScheduleApplication;		//## link itsScheduleApplication 
    
    protected SmokeDetector itsSmokeDetector;		//## link itsSmokeDetector 
    
    //#[ ignore 
    public static final int RiJNonState=0;
    public static final int activeLift=1;
    public static final int state_4=2;
    public static final int mode=3;
    public static final int normalMode=4;
    public static final int alarmMode=5;
    public static final int state_3=6;
    public static final int startedMoving=7;
    public static final int sensorDetectedNextFloor=8;
    public static final int moving=9;
    public static final int liftStopping=10;
    public static final int liftArrived=11;
    public static final int idle=12;
    public static final int doorsOpen=13;
    public static final int awaitingTasksGenerated=14;
    public static final int activated=15;
    public static final int state_2=16;
    public static final int liftCalled=17;
    public static final int awaitingForCall=18;
    public static final int state_11=19;
    public static final int floorSelected=20;
    public static final int awaitingForFloorSelection=21;
    //#]
    protected int rootState_subState;		//## ignore 
    
    protected int rootState_active;		//## ignore 
    
    protected int state_4_subState;		//## ignore 
    
    protected int state_4_active;		//## ignore 
    
    protected int mode_subState;		//## ignore 
    
    protected int state_3_subState;		//## ignore 
    
    protected int state_3_active;		//## ignore 
    
    protected int state_2_subState;		//## ignore 
    
    protected int state_2_active;		//## ignore 
    
    protected int state_11_subState;		//## ignore 
    
    protected int state_11_active;		//## ignore 
    
    
    //## statechart_method 
    public RiJThread getThread() {
        return reactive.getThread();
    }
    
    //## statechart_method 
    public void schedTimeout(long delay, long tmID, RiJStateReactive reactive) {
        getThread().schedTimeout(delay, tmID, reactive);
    }
    
    //## statechart_method 
    public void unschedTimeout(long tmID, RiJStateReactive reactive) {
        getThread().unschedTimeout(tmID, reactive);
    }
    
    //## statechart_method 
    public boolean isIn(int state) {
        return reactive.isIn(state);
    }
    
    //## statechart_method 
    public boolean isCompleted(int state) {
        return reactive.isCompleted(state);
    }
    
    //## statechart_method 
    public RiJEventConsumer getEventConsumer() {
        return (RiJEventConsumer)reactive;
    }
    
    //## statechart_method 
    public void gen(RiJEvent event) {
        reactive._gen(event);
    }
    
    //## statechart_method 
    public void queueEvent(RiJEvent event) {
        reactive.queueEvent(event);
    }
    
    //## statechart_method 
    public int takeEvent(RiJEvent event) {
        return reactive.takeEvent(event);
    }
    
    // Constructors
    
    //## auto_generated 
    public  Lift(RiJThread p_thread) {
        try {
            animInstance().notifyConstructorEntered(animClassLift.getUserClass(),
               new ArgData[] {
               });
        
        reactive = new Reactive(p_thread);
        {
            itsDoorsLock = new LinkedList<DoorsLock>();
        }
        {
            itsOuterDoor = new LinkedList<OuterDoor>();
        }
        initRelations(p_thread);
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    /**
     * @param floorOfRequest
    */
    //## operation addRequestFromInside(int) 
    public void addRequestFromInside(int floorOfRequest) {
        try {
            animInstance().notifyMethodEntered("addRequestFromInside",
               new ArgData[] {
                   new ArgData(int.class, "floorOfRequest", AnimInstance.animToString(floorOfRequest))
               });
        
        //#[ operation addRequestFromInside(int) 
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation cancelAllRequests() 
    public void cancelAllRequests() {
        try {
            animInstance().notifyMethodEntered("cancelAllRequests",
               new ArgData[] {
               });
        
        //#[ operation cancelAllRequests() 
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation getCurrentFloor() 
    public int getCurrentFloor() {
        try {
            animInstance().notifyMethodEntered("getCurrentFloor",
               new ArgData[] {
               });
        
        //#[ operation getCurrentFloor() 
        return currentFloor;
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation getDirection() 
    public boolean getDirection() {
        try {
            animInstance().notifyMethodEntered("getDirection",
               new ArgData[] {
               });
        
        //#[ operation getDirection() 
        return currentDirection;
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation hasCallForThisFloor() 
    public boolean hasCallForThisFloor() {
        try {
            animInstance().notifyMethodEntered("hasCallForThisFloor",
               new ArgData[] {
               });
        
        //#[ operation hasCallForThisFloor() 
            if((itsScheduleApplication.hasCallForFloor(currentFloor))==true)
            	return true;
            else
            	return false;
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation hasMoreFloorsToProcess() 
    public boolean hasMoreFloorsToProcess() {
        try {
            animInstance().notifyMethodEntered("hasMoreFloorsToProcess",
               new ArgData[] {
               });
        
        //#[ operation hasMoreFloorsToProcess() 
        boolean anyMore=false;
        boolean[] floors = itsScheduleApplication.getRequestedFloors();
        for(int i=0; i<floors.length; i++)
        {
         	if(floors[i] == true)
         	{
         		anyMore = true;
         		break;
         	}  	
        }
        
        if(anyMore == true)
          return true;
        else return false;
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation hasMoreRequests() 
    public void hasMoreRequests() {
        try {
            animInstance().notifyMethodEntered("hasMoreRequests",
               new ArgData[] {
               });
        
        //#[ operation hasMoreRequests() 
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation moveToNextFloor() 
    public void moveToNextFloor() {
        try {
            animInstance().notifyMethodEntered("moveToNextFloor",
               new ArgData[] {
               });
        
        //#[ operation moveToNextFloor() 
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation needToChangeDirection() 
    public boolean needToChangeDirection() {
        try {
            animInstance().notifyMethodEntered("needToChangeDirection",
               new ArgData[] {
               });
        
        //#[ operation needToChangeDirection() 
        boolean anyMore=false; 
        boolean[] floors = itsScheduleApplication.getRequestedFloors();
        if(currentDirection == true) //elevator goes up
        {
        	for(int i=currentFloor+1; i<floors.length; i++)
        	{
         		if(floors[i] == true)
         		{
         		anyMore = true;
         		break;
         		}  
         	}	
        }
        else if(currentDirection == false)
        {
            for(int i=currentFloor-1; i>=0; i--)
        	{
         		if(floors[i] == true)
         		{
         		anyMore = true;
         		break;
         		}  	
             }
        
        }
        
        if(anyMore == false)	// no more floors in the same direction
          return true;
        else 
          return false;
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation openDoor() 
    public void openDoor() {
        try {
            animInstance().notifyMethodEntered("openDoor",
               new ArgData[] {
               });
        
        //#[ operation openDoor() 
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation triggerAlarm() 
    public void triggerAlarm() {
        try {
            animInstance().notifyMethodEntered("triggerAlarm",
               new ArgData[] {
               });
        
        //#[ operation triggerAlarm() 
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## auto_generated 
    public boolean getCurrentDirection() {
        return currentDirection;
    }
    
    //## auto_generated 
    public void setCurrentDirection(boolean p_currentDirection) {
        currentDirection = p_currentDirection;
    }
    
    //## auto_generated 
    public void setCurrentFloor(int p_currentFloor) {
        currentFloor = p_currentFloor;
    }
    
    //## auto_generated 
    public int getFloorsCount() {
        return floorsCount;
    }
    
    //## auto_generated 
    public void setFloorsCount(int p_floorsCount) {
        floorsCount = p_floorsCount;
    }
    
    //## auto_generated 
    public int getNextFloor() {
        return nextFloor;
    }
    
    //## auto_generated 
    public void setNextFloor(int p_nextFloor) {
        nextFloor = p_nextFloor;
    }
    
    //## auto_generated 
    public int getRequestedFloor() {
        return requestedFloor;
    }
    
    //## auto_generated 
    public void setRequestedFloor(int p_requestedFloor) {
        requestedFloor = p_requestedFloor;
    }
    
    //## auto_generated 
    public boolean getStop() {
        return stop;
    }
    
    //## auto_generated 
    public void setStop(boolean p_stop) {
        stop = p_stop;
    }
    
    //## auto_generated 
    public Alarm getItsAlarm() {
        return itsAlarm;
    }
    
    //## auto_generated 
    public void __setItsAlarm(Alarm p_Alarm) {
        itsAlarm = p_Alarm;
        if(p_Alarm != null)
            {
                animInstance().notifyRelationAdded("itsAlarm", p_Alarm);
            }
        else
            {
                animInstance().notifyRelationCleared("itsAlarm");
            }
    }
    
    //## auto_generated 
    public void _setItsAlarm(Alarm p_Alarm) {
        if(itsAlarm != null)
            {
                itsAlarm.__setItsLift(null);
            }
        __setItsAlarm(p_Alarm);
    }
    
    //## auto_generated 
    public void setItsAlarm(Alarm p_Alarm) {
        if(p_Alarm != null)
            {
                p_Alarm._setItsLift(this);
            }
        _setItsAlarm(p_Alarm);
    }
    
    //## auto_generated 
    public void _clearItsAlarm() {
        animInstance().notifyRelationCleared("itsAlarm");
        itsAlarm = null;
    }
    
    //## auto_generated 
    public AlarmBreakingDetector getItsAlarmBreakingDetector() {
        return itsAlarmBreakingDetector;
    }
    
    //## auto_generated 
    public void __setItsAlarmBreakingDetector(AlarmBreakingDetector p_AlarmBreakingDetector) {
        itsAlarmBreakingDetector = p_AlarmBreakingDetector;
        if(p_AlarmBreakingDetector != null)
            {
                animInstance().notifyRelationAdded("itsAlarmBreakingDetector", p_AlarmBreakingDetector);
            }
        else
            {
                animInstance().notifyRelationCleared("itsAlarmBreakingDetector");
            }
    }
    
    //## auto_generated 
    public void _setItsAlarmBreakingDetector(AlarmBreakingDetector p_AlarmBreakingDetector) {
        if(itsAlarmBreakingDetector != null)
            {
                itsAlarmBreakingDetector.__setItsLift(null);
            }
        __setItsAlarmBreakingDetector(p_AlarmBreakingDetector);
    }
    
    //## auto_generated 
    public AlarmBreakingDetector newItsAlarmBreakingDetector() {
        itsAlarmBreakingDetector = new AlarmBreakingDetector();
        itsAlarmBreakingDetector._setItsLift(this);
        animInstance().notifyRelationAdded("itsAlarmBreakingDetector", itsAlarmBreakingDetector);
        return itsAlarmBreakingDetector;
    }
    
    //## auto_generated 
    public void deleteItsAlarmBreakingDetector() {
        itsAlarmBreakingDetector.__setItsLift(null);
        animInstance().notifyRelationRemoved("itsAlarmBreakingDetector", itsAlarmBreakingDetector);
        itsAlarmBreakingDetector=null;
    }
    
    //## auto_generated 
    public Controller getItsController() {
        return itsController;
    }
    
    //## auto_generated 
    public void __setItsController(Controller p_Controller) {
        itsController = p_Controller;
        if(p_Controller != null)
            {
                animInstance().notifyRelationAdded("itsController", p_Controller);
            }
        else
            {
                animInstance().notifyRelationCleared("itsController");
            }
    }
    
    //## auto_generated 
    public void _setItsController(Controller p_Controller) {
        if(itsController != null)
            {
                itsController.__setItsLift(null);
            }
        __setItsController(p_Controller);
    }
    
    //## auto_generated 
    public void setItsController(Controller p_Controller) {
        if(p_Controller != null)
            {
                p_Controller._setItsLift(this);
            }
        _setItsController(p_Controller);
    }
    
    //## auto_generated 
    public void _clearItsController() {
        animInstance().notifyRelationCleared("itsController");
        itsController = null;
    }
    
    //## auto_generated 
    public ListIterator<DoorsLock> getItsDoorsLock() {
        ListIterator<DoorsLock> iter = itsDoorsLock.listIterator();
        return iter;
    }
    
    //## auto_generated 
    public void _addItsDoorsLock(DoorsLock p_DoorsLock) {
        if(p_DoorsLock != null)
            {
                animInstance().notifyRelationAdded("itsDoorsLock", p_DoorsLock);
            }
        else
            {
                animInstance().notifyRelationCleared("itsDoorsLock");
            }
        itsDoorsLock.add(p_DoorsLock);
    }
    
    //## auto_generated 
    public DoorsLock newItsDoorsLock() {
        DoorsLock newDoorsLock = new DoorsLock(getThread());
        newDoorsLock._setItsLift(this);
        itsDoorsLock.add(newDoorsLock);
        animInstance().notifyRelationAdded("itsDoorsLock", newDoorsLock);
        return newDoorsLock;
    }
    
    //## auto_generated 
    public void _removeItsDoorsLock(DoorsLock p_DoorsLock) {
        animInstance().notifyRelationRemoved("itsDoorsLock", p_DoorsLock);
        itsDoorsLock.remove(p_DoorsLock);
    }
    
    //## auto_generated 
    public void deleteItsDoorsLock(DoorsLock p_DoorsLock) {
        p_DoorsLock._setItsLift(null);
        itsDoorsLock.remove(p_DoorsLock);
        animInstance().notifyRelationRemoved("itsDoorsLock", p_DoorsLock);
        p_DoorsLock=null;
    }
    
    //## auto_generated 
    public Engine getItsEngine() {
        return itsEngine;
    }
    
    //## auto_generated 
    public void __setItsEngine(Engine p_Engine) {
        itsEngine = p_Engine;
        if(p_Engine != null)
            {
                animInstance().notifyRelationAdded("itsEngine", p_Engine);
            }
        else
            {
                animInstance().notifyRelationCleared("itsEngine");
            }
    }
    
    //## auto_generated 
    public void _setItsEngine(Engine p_Engine) {
        if(itsEngine != null)
            {
                itsEngine.__setItsLift(null);
            }
        __setItsEngine(p_Engine);
    }
    
    //## auto_generated 
    public void setItsEngine(Engine p_Engine) {
        if(p_Engine != null)
            {
                p_Engine._setItsLift(this);
            }
        _setItsEngine(p_Engine);
    }
    
    //## auto_generated 
    public void _clearItsEngine() {
        animInstance().notifyRelationCleared("itsEngine");
        itsEngine = null;
    }
    
    //## auto_generated 
    public IndoorDisplay getItsIndoorDisplay() {
        return itsIndoorDisplay;
    }
    
    //## auto_generated 
    public void __setItsIndoorDisplay(IndoorDisplay p_IndoorDisplay) {
        itsIndoorDisplay = p_IndoorDisplay;
        if(p_IndoorDisplay != null)
            {
                animInstance().notifyRelationAdded("itsIndoorDisplay", p_IndoorDisplay);
            }
        else
            {
                animInstance().notifyRelationCleared("itsIndoorDisplay");
            }
    }
    
    //## auto_generated 
    public void _setItsIndoorDisplay(IndoorDisplay p_IndoorDisplay) {
        if(itsIndoorDisplay != null)
            {
                itsIndoorDisplay.__setItsLift(null);
            }
        __setItsIndoorDisplay(p_IndoorDisplay);
    }
    
    //## auto_generated 
    public IndoorDisplay newItsIndoorDisplay(RiJThread p_thread) {
        itsIndoorDisplay = new IndoorDisplay(p_thread);
        itsIndoorDisplay._setItsLift(this);
        animInstance().notifyRelationAdded("itsIndoorDisplay", itsIndoorDisplay);
        return itsIndoorDisplay;
    }
    
    //## auto_generated 
    public void deleteItsIndoorDisplay() {
        itsIndoorDisplay.__setItsLift(null);
        animInstance().notifyRelationRemoved("itsIndoorDisplay", itsIndoorDisplay);
        itsIndoorDisplay=null;
    }
    
    //## auto_generated 
    public InnerDoor getItsInnerDoor() {
        return itsInnerDoor;
    }
    
    //## auto_generated 
    public void __setItsInnerDoor(InnerDoor p_InnerDoor) {
        itsInnerDoor = p_InnerDoor;
        if(p_InnerDoor != null)
            {
                animInstance().notifyRelationAdded("itsInnerDoor", p_InnerDoor);
            }
        else
            {
                animInstance().notifyRelationCleared("itsInnerDoor");
            }
    }
    
    //## auto_generated 
    public void _setItsInnerDoor(InnerDoor p_InnerDoor) {
        if(itsInnerDoor != null)
            {
                itsInnerDoor.__setItsLift(null);
            }
        __setItsInnerDoor(p_InnerDoor);
    }
    
    //## auto_generated 
    public InnerDoor newItsInnerDoor(RiJThread p_thread) {
        itsInnerDoor = new InnerDoor(p_thread);
        itsInnerDoor._setItsLift(this);
        animInstance().notifyRelationAdded("itsInnerDoor", itsInnerDoor);
        return itsInnerDoor;
    }
    
    //## auto_generated 
    public void deleteItsInnerDoor() {
        itsInnerDoor.__setItsLift(null);
        animInstance().notifyRelationRemoved("itsInnerDoor", itsInnerDoor);
        itsInnerDoor=null;
    }
    
    //## auto_generated 
    public Lights getItsLights() {
        return itsLights;
    }
    
    //## auto_generated 
    public void __setItsLights(Lights p_Lights) {
        itsLights = p_Lights;
        if(p_Lights != null)
            {
                animInstance().notifyRelationAdded("itsLights", p_Lights);
            }
        else
            {
                animInstance().notifyRelationCleared("itsLights");
            }
    }
    
    //## auto_generated 
    public void _setItsLights(Lights p_Lights) {
        if(itsLights != null)
            {
                itsLights.__setItsLift(null);
            }
        __setItsLights(p_Lights);
    }
    
    //## auto_generated 
    public Lights newItsLights() {
        itsLights = new Lights();
        itsLights._setItsLift(this);
        animInstance().notifyRelationAdded("itsLights", itsLights);
        return itsLights;
    }
    
    //## auto_generated 
    public void deleteItsLights() {
        itsLights.__setItsLift(null);
        animInstance().notifyRelationRemoved("itsLights", itsLights);
        itsLights=null;
    }
    
    //## auto_generated 
    public LocationDetector getItsLocationDetector() {
        return itsLocationDetector;
    }
    
    //## auto_generated 
    public void __setItsLocationDetector(LocationDetector p_LocationDetector) {
        itsLocationDetector = p_LocationDetector;
        if(p_LocationDetector != null)
            {
                animInstance().notifyRelationAdded("itsLocationDetector", p_LocationDetector);
            }
        else
            {
                animInstance().notifyRelationCleared("itsLocationDetector");
            }
    }
    
    //## auto_generated 
    public void _setItsLocationDetector(LocationDetector p_LocationDetector) {
        if(itsLocationDetector != null)
            {
                itsLocationDetector.__setItsLift(null);
            }
        __setItsLocationDetector(p_LocationDetector);
    }
    
    //## auto_generated 
    public LocationDetector newItsLocationDetector() {
        itsLocationDetector = new LocationDetector();
        itsLocationDetector._setItsLift(this);
        animInstance().notifyRelationAdded("itsLocationDetector", itsLocationDetector);
        return itsLocationDetector;
    }
    
    //## auto_generated 
    public void deleteItsLocationDetector() {
        itsLocationDetector.__setItsLift(null);
        animInstance().notifyRelationRemoved("itsLocationDetector", itsLocationDetector);
        itsLocationDetector=null;
    }
    
    //## auto_generated 
    public ObstacleInDoorDetector getItsObstacleInDoorDetector() {
        return itsObstacleInDoorDetector;
    }
    
    //## auto_generated 
    public void __setItsObstacleInDoorDetector(ObstacleInDoorDetector p_ObstacleInDoorDetector) {
        itsObstacleInDoorDetector = p_ObstacleInDoorDetector;
        if(p_ObstacleInDoorDetector != null)
            {
                animInstance().notifyRelationAdded("itsObstacleInDoorDetector", p_ObstacleInDoorDetector);
            }
        else
            {
                animInstance().notifyRelationCleared("itsObstacleInDoorDetector");
            }
    }
    
    //## auto_generated 
    public void _setItsObstacleInDoorDetector(ObstacleInDoorDetector p_ObstacleInDoorDetector) {
        if(itsObstacleInDoorDetector != null)
            {
                itsObstacleInDoorDetector.__setItsLift(null);
            }
        __setItsObstacleInDoorDetector(p_ObstacleInDoorDetector);
    }
    
    //## auto_generated 
    public ObstacleInDoorDetector newItsObstacleInDoorDetector() {
        itsObstacleInDoorDetector = new ObstacleInDoorDetector();
        itsObstacleInDoorDetector._setItsLift(this);
        animInstance().notifyRelationAdded("itsObstacleInDoorDetector", itsObstacleInDoorDetector);
        return itsObstacleInDoorDetector;
    }
    
    //## auto_generated 
    public void deleteItsObstacleInDoorDetector() {
        itsObstacleInDoorDetector.__setItsLift(null);
        animInstance().notifyRelationRemoved("itsObstacleInDoorDetector", itsObstacleInDoorDetector);
        itsObstacleInDoorDetector=null;
    }
    
    //## auto_generated 
    public ListIterator<OuterDoor> getItsOuterDoor() {
        ListIterator<OuterDoor> iter = itsOuterDoor.listIterator();
        return iter;
    }
    
    //## auto_generated 
    public void addItsOuterDoor(OuterDoor p_OuterDoor) {
        if(p_OuterDoor != null)
            {
                animInstance().notifyRelationAdded("itsOuterDoor", p_OuterDoor);
            }
        else
            {
                animInstance().notifyRelationCleared("itsOuterDoor");
            }
        itsOuterDoor.add(p_OuterDoor);
    }
    
    //## auto_generated 
    public void removeItsOuterDoor(OuterDoor p_OuterDoor) {
        animInstance().notifyRelationRemoved("itsOuterDoor", p_OuterDoor);
        itsOuterDoor.remove(p_OuterDoor);
    }
    
    //## auto_generated 
    public void clearItsOuterDoor() {
        animInstance().notifyRelationCleared("itsOuterDoor");
        itsOuterDoor.clear();
    }
    
    //## auto_generated 
    public OverloadDetector getItsOverloadDetector() {
        return itsOverloadDetector;
    }
    
    //## auto_generated 
    public void __setItsOverloadDetector(OverloadDetector p_OverloadDetector) {
        itsOverloadDetector = p_OverloadDetector;
        if(p_OverloadDetector != null)
            {
                animInstance().notifyRelationAdded("itsOverloadDetector", p_OverloadDetector);
            }
        else
            {
                animInstance().notifyRelationCleared("itsOverloadDetector");
            }
    }
    
    //## auto_generated 
    public void _setItsOverloadDetector(OverloadDetector p_OverloadDetector) {
        if(itsOverloadDetector != null)
            {
                itsOverloadDetector.__setItsLift(null);
            }
        __setItsOverloadDetector(p_OverloadDetector);
    }
    
    //## auto_generated 
    public OverloadDetector newItsOverloadDetector() {
        itsOverloadDetector = new OverloadDetector();
        itsOverloadDetector._setItsLift(this);
        animInstance().notifyRelationAdded("itsOverloadDetector", itsOverloadDetector);
        return itsOverloadDetector;
    }
    
    //## auto_generated 
    public void deleteItsOverloadDetector() {
        itsOverloadDetector.__setItsLift(null);
        animInstance().notifyRelationRemoved("itsOverloadDetector", itsOverloadDetector);
        itsOverloadDetector=null;
    }
    
    //## auto_generated 
    public ScheduleApplication getItsScheduleApplication() {
        return itsScheduleApplication;
    }
    
    //## auto_generated 
    public void __setItsScheduleApplication(ScheduleApplication p_ScheduleApplication) {
        itsScheduleApplication = p_ScheduleApplication;
        if(p_ScheduleApplication != null)
            {
                animInstance().notifyRelationAdded("itsScheduleApplication", p_ScheduleApplication);
            }
        else
            {
                animInstance().notifyRelationCleared("itsScheduleApplication");
            }
    }
    
    //## auto_generated 
    public void _setItsScheduleApplication(ScheduleApplication p_ScheduleApplication) {
        if(itsScheduleApplication != null)
            {
                itsScheduleApplication.__setItsLift(null);
            }
        __setItsScheduleApplication(p_ScheduleApplication);
    }
    
    //## auto_generated 
    public ScheduleApplication newItsScheduleApplication(RiJThread p_thread) {
        itsScheduleApplication = new ScheduleApplication(p_thread);
        itsScheduleApplication._setItsLift(this);
        animInstance().notifyRelationAdded("itsScheduleApplication", itsScheduleApplication);
        return itsScheduleApplication;
    }
    
    //## auto_generated 
    public void deleteItsScheduleApplication() {
        itsScheduleApplication.__setItsLift(null);
        animInstance().notifyRelationRemoved("itsScheduleApplication", itsScheduleApplication);
        itsScheduleApplication=null;
    }
    
    //## auto_generated 
    public SmokeDetector getItsSmokeDetector() {
        return itsSmokeDetector;
    }
    
    //## auto_generated 
    public void __setItsSmokeDetector(SmokeDetector p_SmokeDetector) {
        itsSmokeDetector = p_SmokeDetector;
        if(p_SmokeDetector != null)
            {
                animInstance().notifyRelationAdded("itsSmokeDetector", p_SmokeDetector);
            }
        else
            {
                animInstance().notifyRelationCleared("itsSmokeDetector");
            }
    }
    
    //## auto_generated 
    public void _setItsSmokeDetector(SmokeDetector p_SmokeDetector) {
        if(itsSmokeDetector != null)
            {
                itsSmokeDetector.__setItsLift(null);
            }
        __setItsSmokeDetector(p_SmokeDetector);
    }
    
    //## auto_generated 
    public SmokeDetector newItsSmokeDetector() {
        itsSmokeDetector = new SmokeDetector();
        itsSmokeDetector._setItsLift(this);
        animInstance().notifyRelationAdded("itsSmokeDetector", itsSmokeDetector);
        return itsSmokeDetector;
    }
    
    //## auto_generated 
    public void deleteItsSmokeDetector() {
        itsSmokeDetector.__setItsLift(null);
        animInstance().notifyRelationRemoved("itsSmokeDetector", itsSmokeDetector);
        itsSmokeDetector=null;
    }
    
    //## auto_generated 
    protected void initRelations(RiJThread p_thread) {
        itsAlarmBreakingDetector = newItsAlarmBreakingDetector();
        itsIndoorDisplay = newItsIndoorDisplay(p_thread);
        itsInnerDoor = newItsInnerDoor(p_thread);
        itsLights = newItsLights();
        itsLocationDetector = newItsLocationDetector();
        itsObstacleInDoorDetector = newItsObstacleInDoorDetector();
        itsOverloadDetector = newItsOverloadDetector();
        itsScheduleApplication = newItsScheduleApplication(p_thread);
        itsSmokeDetector = newItsSmokeDetector();
    }
    
    //## auto_generated 
    public boolean startBehavior() {
        boolean done = true;
        {
            ListIterator<DoorsLock> iter = itsDoorsLock.listIterator();
            while (iter.hasNext()){
                done &= (itsDoorsLock.get(iter.nextIndex())).startBehavior();
                iter.next();
            }
        }
        done &= itsIndoorDisplay.startBehavior();
        done &= itsInnerDoor.startBehavior();
        done &= itsScheduleApplication.startBehavior();
        done &= reactive.startBehavior();
        return done;
    }
    
    //## ignore 
    public class Reactive extends RiJStateReactive implements AnimatedReactive {
        
        // Default constructor 
        public Reactive() {
            this(RiJMainThread.instance());
        }
        
        
        // Constructors
        
        public  Reactive(RiJThread p_thread) {
            super(p_thread);
            initStatechart();
        }
        
        //## statechart_method 
        public boolean isIn(int state) {
            if(state_11 == state)
                {
                    return isIn(activeLift);
                }
            if(state_11_subState == state)
                {
                    return true;
                }
            if(state_2 == state)
                {
                    return isIn(activeLift);
                }
            if(state_2_subState == state)
                {
                    return true;
                }
            if(state_3 == state)
                {
                    return isIn(activeLift);
                }
            if(state_3_subState == state)
                {
                    return true;
                }
            if(mode_subState == state)
                {
                    return true;
                }
            if(state_4 == state)
                {
                    return isIn(activeLift);
                }
            if(state_4_subState == state)
                {
                    return true;
                }
            if(rootState_subState == state)
                {
                    return true;
                }
            return false;
        }
        
        //## statechart_method 
        public boolean isCompleted(int state) {
            return true;
        }
        
        //## statechart_method 
        public void rootState_add(AnimStates animStates) {
            animStates.add("ROOT");
            if(rootState_subState == activeLift)
                {
                    activeLift_add(animStates);
                }
        }
        
        //## statechart_method 
        public void rootState_entDef() {
            {
                rootState_enter();
                rootStateEntDef();
            }
        }
        
        //## statechart_method 
        public int rootState_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(rootState_active == activeLift)
                {
                    res = activeLift_dispatchEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void activeLift_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift");
            state_3_add(animStates);
            state_4_add(animStates);
            state_2_add(animStates);
            state_11_add(animStates);
        }
        
        //## statechart_method 
        public int activeLift_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(state_3_dispatchEvent(id) >= 0)
                {
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                    if(!isIn(activeLift))
                        {
                            return res;
                        }
                }
            if(state_4_dispatchEvent(id) >= 0)
                {
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                    if(!isIn(activeLift))
                        {
                            return res;
                        }
                }
            if(state_2_dispatchEvent(id) >= 0)
                {
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                    if(!isIn(activeLift))
                        {
                            return res;
                        }
                }
            if(state_11_dispatchEvent(id) >= 0)
                {
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                    if(!isIn(activeLift))
                        {
                            return res;
                        }
                }
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = activeLift_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void state_4_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_4");
            if(state_4_subState == mode)
                {
                    mode_add(animStates);
                }
        }
        
        //## statechart_method 
        public int state_4_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            switch (state_4_active) {
                case normalMode:
                {
                    res = normalMode_takeEvent(id);
                }
                break;
                case alarmMode:
                {
                    res = alarmMode_takeEvent(id);
                }
                break;
                default:
                    break;
            }
            return res;
        }
        
        //## statechart_method 
        public void mode_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_4.mode");
            switch (mode_subState) {
                case normalMode:
                {
                    normalMode_add(animStates);
                }
                break;
                case alarmMode:
                {
                    alarmMode_add(animStates);
                }
                break;
                default:
                    break;
            }
        }
        
        //## statechart_method 
        public void normalMode_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_4.mode.normalMode");
        }
        
        //## statechart_method 
        public void alarmMode_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_4.mode.alarmMode");
        }
        
        //## statechart_method 
        public void state_3_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_3");
            switch (state_3_subState) {
                case activated:
                {
                    activated_add(animStates);
                }
                break;
                case idle:
                {
                    idle_add(animStates);
                }
                break;
                case awaitingTasksGenerated:
                {
                    awaitingTasksGenerated_add(animStates);
                }
                break;
                case liftArrived:
                {
                    liftArrived_add(animStates);
                }
                break;
                case startedMoving:
                {
                    startedMoving_add(animStates);
                }
                break;
                case sensorDetectedNextFloor:
                {
                    sensorDetectedNextFloor_add(animStates);
                }
                break;
                case liftStopping:
                {
                    liftStopping_add(animStates);
                }
                break;
                case doorsOpen:
                {
                    doorsOpen_add(animStates);
                }
                break;
                case moving:
                {
                    moving_add(animStates);
                }
                break;
                default:
                    break;
            }
        }
        
        //## statechart_method 
        public int state_3_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            switch (state_3_active) {
                case activated:
                {
                    res = activated_takeEvent(id);
                }
                break;
                case idle:
                {
                    res = idle_takeEvent(id);
                }
                break;
                case awaitingTasksGenerated:
                {
                    res = awaitingTasksGenerated_takeEvent(id);
                }
                break;
                case liftArrived:
                {
                    res = liftArrived_takeEvent(id);
                }
                break;
                case startedMoving:
                {
                    res = startedMoving_takeEvent(id);
                }
                break;
                case sensorDetectedNextFloor:
                {
                    res = sensorDetectedNextFloor_takeEvent(id);
                }
                break;
                case liftStopping:
                {
                    res = liftStopping_takeEvent(id);
                }
                break;
                case doorsOpen:
                {
                    res = doorsOpen_takeEvent(id);
                }
                break;
                case moving:
                {
                    res = moving_takeEvent(id);
                }
                break;
                default:
                    break;
            }
            return res;
        }
        
        //## statechart_method 
        public void startedMoving_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_3.startedMoving");
        }
        
        //## statechart_method 
        public void sensorDetectedNextFloor_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_3.sensorDetectedNextFloor");
        }
        
        //## statechart_method 
        public void moving_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_3.moving");
        }
        
        //## statechart_method 
        public void liftStopping_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_3.liftStopping");
        }
        
        //## statechart_method 
        public void liftArrived_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_3.liftArrived");
        }
        
        //## statechart_method 
        public void idle_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_3.idle");
        }
        
        //## statechart_method 
        public void doorsOpen_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_3.doorsOpen");
        }
        
        //## statechart_method 
        public void awaitingTasksGenerated_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_3.awaitingTasksGenerated");
        }
        
        //## statechart_method 
        public void activated_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_3.activated");
        }
        
        //## statechart_method 
        public void state_2_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_2");
            switch (state_2_subState) {
                case awaitingForCall:
                {
                    awaitingForCall_add(animStates);
                }
                break;
                case liftCalled:
                {
                    liftCalled_add(animStates);
                }
                break;
                default:
                    break;
            }
        }
        
        //## statechart_method 
        public int state_2_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            switch (state_2_active) {
                case awaitingForCall:
                {
                    res = awaitingForCall_takeEvent(id);
                }
                break;
                case liftCalled:
                {
                    res = liftCalled_takeEvent(id);
                }
                break;
                default:
                    break;
            }
            return res;
        }
        
        //## statechart_method 
        public void liftCalled_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_2.liftCalled");
        }
        
        //## statechart_method 
        public void awaitingForCall_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_2.awaitingForCall");
        }
        
        //## statechart_method 
        public void state_11_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_11");
            switch (state_11_subState) {
                case awaitingForFloorSelection:
                {
                    awaitingForFloorSelection_add(animStates);
                }
                break;
                case floorSelected:
                {
                    floorSelected_add(animStates);
                }
                break;
                default:
                    break;
            }
        }
        
        //## statechart_method 
        public int state_11_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            switch (state_11_active) {
                case awaitingForFloorSelection:
                {
                    res = awaitingForFloorSelection_takeEvent(id);
                }
                break;
                case floorSelected:
                {
                    res = floorSelected_takeEvent(id);
                }
                break;
                default:
                    break;
            }
            return res;
        }
        
        //## statechart_method 
        public void floorSelected_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_11.floorSelected");
        }
        
        //## statechart_method 
        public void awaitingForFloorSelection_add(AnimStates animStates) {
            animStates.add("ROOT.activeLift.state_11.awaitingForFloorSelection");
        }
        
        //## auto_generated 
        protected void initStatechart() {
            rootState_subState = RiJNonState;
            rootState_active = RiJNonState;
            state_4_subState = RiJNonState;
            state_4_active = RiJNonState;
            mode_subState = RiJNonState;
            state_3_subState = RiJNonState;
            state_3_active = RiJNonState;
            state_2_subState = RiJNonState;
            state_2_active = RiJNonState;
            state_11_subState = RiJNonState;
            state_11_active = RiJNonState;
        }
        
        //## statechart_method 
        public void floorSelectedExit() {
        }
        
        //## statechart_method 
        public void liftCalled_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_2.liftCalled");
            pushNullConfig();
            state_2_subState = liftCalled;
            state_2_active = liftCalled;
            liftCalledEnter();
        }
        
        //## statechart_method 
        public void state_2Enter() {
        }
        
        //## statechart_method 
        public void activatedEnter() {
            //#[ state ROOT.activeLift.state_3.activated.(Entry) 
            System.out.println("inicjalizujemy!");
            itsScheduleApplication.newLiftCalls();
            for(int a : itsScheduleApplication.getLiftCalls())
            	System.out.println("mamy2 " + a);
            //#]
        }
        
        //## statechart_method 
        public void awaitingTasksGeneratedEnter() {
            //#[ state ROOT.activeLift.state_3.awaitingTasksGenerated.(Entry) 
            itsScheduleApplication.setTaskQueue(false);
            //#]
        }
        
        //## statechart_method 
        public void idle_entDef() {
            idle_enter();
        }
        
        //## statechart_method 
        public int liftArrived_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(OpenDoors.OpenDoors_CargoLiftSystem_id))
                {
                    res = liftArrivedTakeOpenDoors();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int liftStoppingTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("25");
            liftStopping_exit();
            liftArrived_entDef();
            animInstance().notifyTransitionEnded("25");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void state_3EntDef() {
            animInstance().notifyTransitionStarted("0");
            activated_entDef();
            animInstance().notifyTransitionEnded("0");
        }
        
        //## statechart_method 
        public void state_3_entDef() {
            state_3_enter();
            state_3EntDef();
        }
        
        //## statechart_method 
        public void alarmMode_entDef() {
            alarmMode_enter();
        }
        
        //## statechart_method 
        public void mode_exit() {
            switch (mode_subState) {
                case normalMode:
                {
                    normalMode_exit();
                }
                break;
                case alarmMode:
                {
                    alarmMode_exit();
                }
                break;
                default:
                    break;
            }
            mode_subState = RiJNonState;
            modeExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_4.mode");
        }
        
        //## statechart_method 
        public void state_4_exit() {
            if(state_4_subState == mode)
                {
                    mode_exit();
                }
            state_4_subState = RiJNonState;
            state_4Exit();
            animInstance().notifyStateExited("ROOT.activeLift.state_4");
        }
        
        //## statechart_method 
        public void state_4EntDef() {
            mode_entDef();
        }
        
        //## statechart_method 
        public void awaitingForFloorSelectionEnter() {
        }
        
        //## statechart_method 
        public void state_11_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_11");
            state_11Enter();
        }
        
        //## statechart_method 
        public int liftCalledTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("13");
            liftCalled_exit();
            awaitingForCall_entDef();
            animInstance().notifyTransitionEnded("13");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void awaitingTasksGenerated_entDef() {
            awaitingTasksGenerated_enter();
        }
        
        //## statechart_method 
        public int doorsOpenTakedoorClosed() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            //## transition 20 
            if(currentFloor != requestedFloor)
                {
                    animInstance().notifyTransitionStarted("4");
                    animInstance().notifyTransitionStarted("20");
                    doorsOpen_exit();
                    moving_entDef();
                    animInstance().notifyTransitionEnded("20");
                    animInstance().notifyTransitionEnded("4");
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            else
                {
                    animInstance().notifyTransitionStarted("4");
                    animInstance().notifyTransitionStarted("21");
                    doorsOpen_exit();
                    awaitingTasksGenerated_entDef();
                    animInstance().notifyTransitionEnded("21");
                    animInstance().notifyTransitionEnded("4");
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            return res;
        }
        
        //## statechart_method 
        public void idleEnter() {
            //#[ state ROOT.activeLift.state_3.idle.(Entry) 
            System.out.println("Lift is idle");
            //#]
        }
        
        //## statechart_method 
        public void moving_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_3.moving");
            pushNullConfig();
            state_3_subState = moving;
            state_3_active = moving;
            movingEnter();
        }
        
        //## statechart_method 
        public void startedMoving_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_3.startedMoving");
            pushNullConfig();
            state_3_subState = startedMoving;
            state_3_active = startedMoving;
            startedMovingEnter();
        }
        
        //## statechart_method 
        public void state_3_exit() {
            switch (state_3_subState) {
                case activated:
                {
                    activated_exit();
                }
                break;
                case idle:
                {
                    idle_exit();
                }
                break;
                case awaitingTasksGenerated:
                {
                    awaitingTasksGenerated_exit();
                }
                break;
                case liftArrived:
                {
                    liftArrived_exit();
                }
                break;
                case startedMoving:
                {
                    startedMoving_exit();
                }
                break;
                case sensorDetectedNextFloor:
                {
                    sensorDetectedNextFloor_exit();
                }
                break;
                case liftStopping:
                {
                    liftStopping_exit();
                }
                break;
                case doorsOpen:
                {
                    doorsOpen_exit();
                }
                break;
                case moving:
                {
                    moving_exit();
                }
                break;
                default:
                    break;
            }
            state_3_subState = RiJNonState;
            state_3Exit();
            animInstance().notifyStateExited("ROOT.activeLift.state_3");
        }
        
        //## statechart_method 
        public int awaitingForFloorSelectionTakeSelectFloor() {
            SelectFloor params = (SelectFloor) event;
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("24");
            awaitingForFloorSelection_exit();
            //#[ transition 24 
            if(!itsScheduleApplication.getSelectedFloors().contains(params.floor))
              itsScheduleApplication.addSelectedFloors(params.floor);
            //#]
            floorSelected_entDef();
            animInstance().notifyTransitionEnded("24");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void awaitingForCallExit() {
        }
        
        //## statechart_method 
        public void movingExit() {
        }
        
        //## statechart_method 
        public void startedMoving_entDef() {
            startedMoving_enter();
        }
        
        //## statechart_method 
        public int state_3_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public int activeLift_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void awaitingForCall_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_2.awaitingForCall");
            state_2_subState = awaitingForCall;
            state_2_active = awaitingForCall;
            awaitingForCallEnter();
        }
        
        //## statechart_method 
        public void state_2_exit() {
            switch (state_2_subState) {
                case awaitingForCall:
                {
                    awaitingForCall_exit();
                }
                break;
                case liftCalled:
                {
                    liftCalled_exit();
                }
                break;
                default:
                    break;
            }
            state_2_subState = RiJNonState;
            state_2Exit();
            animInstance().notifyStateExited("ROOT.activeLift.state_2");
        }
        
        //## statechart_method 
        public int activatedTakeliftIsDown() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("1");
            activated_exit();
            //#[ transition 1 
            System.out.println("Lift initialized, and is down");
            //#]
            idle_entDef();
            animInstance().notifyTransitionEnded("1");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void activated_exit() {
            activatedExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_3.activated");
        }
        
        //## statechart_method 
        public void awaitingTasksGenerated_exit() {
            popNullConfig();
            awaitingTasksGeneratedExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_3.awaitingTasksGenerated");
        }
        
        //## statechart_method 
        public void doorsOpen_entDef() {
            doorsOpen_enter();
        }
        
        //## statechart_method 
        public void liftStoppingEnter() {
        }
        
        //## statechart_method 
        public void sensorDetectedNextFloorEnter() {
            //#[ state ROOT.activeLift.state_3.sensorDetectedNextFloor.(Entry) 
            if(itsScheduleApplication.ifSelectedFloorsEmpty() == false)
            {if(itsScheduleApplication.getSelectedFloorsContains(currentFloor)) stop = true;
            else stop = false;
            }
            else if(itsScheduleApplication.ifLiftCallsEmpty() == false)
            {
            if(itsScheduleApplication.getLiftCallContains(currentFloor)) stop = true;
            else stop = false;
            }
            
            //#]
        }
        
        //## statechart_method 
        public void awaitingForFloorSelection_exit() {
            awaitingForFloorSelectionExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_11.awaitingForFloorSelection");
        }
        
        //## statechart_method 
        public void floorSelectedEnter() {
        }
        
        //## statechart_method 
        public void idle_exit() {
            idleExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_3.idle");
        }
        
        //## statechart_method 
        public void liftArrivedEnter() {
            //#[ state ROOT.activeLift.state_3.liftArrived.(Entry) 
            //itsInnerDoor.gen(evOpenDoors());
            //itsOuterDoor.gen(OpenDoors());
            itsScheduleApplication.removeFloor(currentFloor);
            //#]
        }
        
        //## statechart_method 
        public void alarmModeEnter() {
        }
        
        //## statechart_method 
        public void normalModeExit() {
        }
        
        //## statechart_method 
        public void modeExit() {
        }
        
        //## statechart_method 
        public void activeLiftExit() {
        }
        
        //## statechart_method 
        public int awaitingForFloorSelection_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(SelectFloor.SelectFloor_CargoLiftSystem_id))
                {
                    res = awaitingForFloorSelectionTakeSelectFloor();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_11_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void floorSelected_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_11.floorSelected");
            pushNullConfig();
            state_11_subState = floorSelected;
            state_11_active = floorSelected;
            floorSelectedEnter();
        }
        
        //## statechart_method 
        public void state_11EntDef() {
            animInstance().notifyTransitionStarted("22");
            //#[ transition 22 
            itsScheduleApplication.newSelectedFloors();
            System.out.println("new selected floors zainicjalizowane!");
            //#]
            awaitingForFloorSelection_entDef();
            animInstance().notifyTransitionEnded("22");
        }
        
        //## statechart_method 
        public void movingEnter() {
            //#[ state ROOT.activeLift.state_3.moving.(Entry) 
            if(currentDirection == true) {
               itsEngine.gen(new evMove(true));
               currentFloor= currentFloor+1;
               System.out.println("Lift is moving up on floor " + currentFloor);
            } else {
               itsEngine.gen(new evMove(false));
               currentFloor= currentFloor-1;
               System.out.println("Lift is moving down on floor " + currentFloor);
            }
            //#]
        }
        
        //## statechart_method 
        public int startedMoving_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = startedMovingTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void alarmMode_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_4.mode.alarmMode");
            mode_subState = alarmMode;
            state_4_active = alarmMode;
            alarmModeEnter();
        }
        
        //## statechart_method 
        public void state_11_entDef() {
            state_11_enter();
            state_11EntDef();
        }
        
        //## statechart_method 
        public int doorsOpen_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(doorClosed.doorClosed_CargoLiftSystem_id))
                {
                    res = doorsOpenTakedoorClosed();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void liftStopping_exit() {
            popNullConfig();
            liftStoppingExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_3.liftStopping");
        }
        
        //## statechart_method 
        public void liftStoppingExit() {
        }
        
        //## statechart_method 
        public void sensorDetectedNextFloor_exit() {
            popNullConfig();
            sensorDetectedNextFloorExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_3.sensorDetectedNextFloor");
        }
        
        //## statechart_method 
        public void sensorDetectedNextFloor_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_3.sensorDetectedNextFloor");
            pushNullConfig();
            state_3_subState = sensorDetectedNextFloor;
            state_3_active = sensorDetectedNextFloor;
            sensorDetectedNextFloorEnter();
        }
        
        //## statechart_method 
        public int mode_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            res = state_4_takeEvent(id);
            return res;
        }
        
        //## statechart_method 
        public void state_4_entDef() {
            state_4_enter();
            state_4EntDef();
        }
        
        //## statechart_method 
        public int rootState_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void floorSelected_exit() {
            popNullConfig();
            floorSelectedExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_11.floorSelected");
        }
        
        //## statechart_method 
        public void state_11Exit() {
        }
        
        //## statechart_method 
        public void activated_entDef() {
            activated_enter();
        }
        
        //## statechart_method 
        public int idleTakedoorClosed() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("9");
            idle_exit();
            idle_entDef();
            animInstance().notifyTransitionEnded("9");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void liftArrived_exit() {
            liftArrivedExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_3.liftArrived");
        }
        
        //## statechart_method 
        public int liftStopping_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = liftStoppingTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void startedMovingEnter() {
            //#[ state ROOT.activeLift.state_3.startedMoving.(Entry) 
            boolean liftCallsEmpty = itsScheduleApplication.ifLiftCallsEmpty();
            boolean selectedFloorsEmpty = itsScheduleApplication.ifSelectedFloorsEmpty();
            System.out.println("Task queue empty: " + itsScheduleApplication.ifTaskQueueEmpty());
            System.out.println("Lift calls empty: " + liftCallsEmpty + " , selected floors empty " +selectedFloorsEmpty ); 
            
            if(!selectedFloorsEmpty) {
            requestedFloor = itsScheduleApplication.getRequestedFloorPoll();
            System.out.println("Lift is going to (floors selected)" + requestedFloor);
            }
            else if(!liftCallsEmpty)
            {
            requestedFloor = itsScheduleApplication.getLiftCallsPoll();
            System.out.println("Lift is going to (lift Calls)" + requestedFloor);
            }
            //#]
        }
        
        //## statechart_method 
        public void alarmMode_exit() {
            alarmModeExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_4.mode.alarmMode");
        }
        
        //## statechart_method 
        public int normalMode_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(alarmTriggered.alarmTriggered_CargoLiftSystem_id))
                {
                    res = normalModeTakealarmTriggered();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = mode_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int state_11_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public int state_2_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public int activated_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(liftIsDown.liftIsDown_CargoLiftSystem_id))
                {
                    res = activatedTakeliftIsDown();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void moving_exit() {
            popNullConfig();
            movingExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_3.moving");
        }
        
        //## statechart_method 
        public void moving_entDef() {
            moving_enter();
        }
        
        //## statechart_method 
        public void rootState_enter() {
            animInstance().notifyStateEntered("ROOT");
            rootStateEnter();
        }
        
        //## statechart_method 
        public void rootStateEnter() {
        }
        
        //## statechart_method 
        public void awaitingForFloorSelectionExit() {
        }
        
        //## statechart_method 
        public int floorSelected_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = floorSelectedTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_11_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void state_11Enter() {
        }
        
        //## statechart_method 
        public int liftCalled_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = liftCalledTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_2_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void state_2Exit() {
        }
        
        //## statechart_method 
        public void liftArrived_entDef() {
            liftArrived_enter();
        }
        
        //## statechart_method 
        public void liftStopping_entDef() {
            liftStopping_enter();
        }
        
        //## statechart_method 
        public int sensorDetectedNextFloor_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = sensorDetectedNextFloorTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void sensorDetectedNextFloor_entDef() {
            sensorDetectedNextFloor_enter();
        }
        
        //## statechart_method 
        public int alarmModeTakealarmFinished() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("7");
            alarmMode_exit();
            normalMode_entDef();
            animInstance().notifyTransitionEnded("7");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void alarmModeExit() {
        }
        
        //## statechart_method 
        public void normalMode_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_4.mode.normalMode");
            mode_subState = normalMode;
            state_4_active = normalMode;
            normalModeEnter();
        }
        
        //## statechart_method 
        public void liftCalledEnter() {
        }
        
        //## statechart_method 
        public void state_2_entDef() {
            state_2_enter();
            state_2EntDef();
        }
        
        //## statechart_method 
        public void activatedExit() {
        }
        
        //## statechart_method 
        public void doorsOpenEnter() {
        }
        
        //## statechart_method 
        public int liftArrivedTakeOpenDoors() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("19");
            liftArrived_exit();
            doorsOpen_entDef();
            animInstance().notifyTransitionEnded("19");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public int movingTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            //## transition 15 
            if(currentFloor != requestedFloor)
                {
                    animInstance().notifyTransitionStarted("15");
                    moving_exit();
                    sensorDetectedNextFloor_entDef();
                    animInstance().notifyTransitionEnded("15");
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            else
                {
                    //## transition 18 
                    if(currentFloor == requestedFloor)
                        {
                            animInstance().notifyTransitionStarted("18");
                            moving_exit();
                            liftArrived_entDef();
                            animInstance().notifyTransitionEnded("18");
                            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                        }
                }
            return res;
        }
        
        //## statechart_method 
        public void startedMoving_exit() {
            popNullConfig();
            startedMovingExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_3.startedMoving");
        }
        
        //## statechart_method 
        public void state_3Exit() {
        }
        
        //## statechart_method 
        public void mode_entDef() {
            mode_enter();
            
            animInstance().notifyTransitionStarted("5");
            normalMode_entDef();
            animInstance().notifyTransitionEnded("5");
        }
        
        //## statechart_method 
        public void activeLiftEnter() {
        }
        
        //## statechart_method 
        public void activeLift_entDef() {
            activeLift_enter();
            state_3_entDef();
            state_4_entDef();
            state_2_entDef();
            state_11_entDef();
        }
        
        //## statechart_method 
        public int floorSelectedTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("23");
            floorSelected_exit();
            awaitingForFloorSelection_entDef();
            animInstance().notifyTransitionEnded("23");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void idle_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_3.idle");
            state_3_subState = idle;
            state_3_active = idle;
            idleEnter();
        }
        
        //## statechart_method 
        public int sensorDetectedNextFloorTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            //## transition 16 
            if(stop == false)
                {
                    animInstance().notifyTransitionStarted("16");
                    sensorDetectedNextFloor_exit();
                    moving_entDef();
                    animInstance().notifyTransitionEnded("16");
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            else
                {
                    //## transition 17 
                    if(stop == true)
                        {
                            animInstance().notifyTransitionStarted("17");
                            sensorDetectedNextFloor_exit();
                            liftStopping_entDef();
                            animInstance().notifyTransitionEnded("17");
                            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                        }
                }
            return res;
        }
        
        //## statechart_method 
        public int alarmModeTakeinAlarmMode() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("8");
            alarmMode_exit();
            alarmMode_entDef();
            animInstance().notifyTransitionEnded("8");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void normalModeEnter() {
        }
        
        //## statechart_method 
        public void state_4Exit() {
        }
        
        //## statechart_method 
        public void rootStateEntDef() {
            activeLift_entDef();
        }
        
        //## statechart_method 
        public void state_11_exit() {
            switch (state_11_subState) {
                case awaitingForFloorSelection:
                {
                    awaitingForFloorSelection_exit();
                }
                break;
                case floorSelected:
                {
                    floorSelected_exit();
                }
                break;
                default:
                    break;
            }
            state_11_subState = RiJNonState;
            state_11Exit();
            animInstance().notifyStateExited("ROOT.activeLift.state_11");
        }
        
        //## statechart_method 
        public void awaitingForCallEnter() {
            //#[ state ROOT.activeLift.state_2.awaitingForCall.(Entry) 
            
            
            //#]
        }
        
        //## statechart_method 
        public int awaitingTasksGeneratedTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            //## transition 3 
            if(itsScheduleApplication.ifTaskQueueEmpty() == false)
                {
                    animInstance().notifyTransitionStarted("3");
                    awaitingTasksGenerated_exit();
                    startedMoving_entDef();
                    animInstance().notifyTransitionEnded("3");
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            else
                {
                    //## transition 14 
                    if(itsScheduleApplication.ifTaskQueueEmpty()==true)
                        {
                            animInstance().notifyTransitionStarted("14");
                            awaitingTasksGenerated_exit();
                            idle_entDef();
                            animInstance().notifyTransitionEnded("14");
                            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                        }
                }
            return res;
        }
        
        //## statechart_method 
        public int startedMovingTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("26");
            startedMoving_exit();
            //#[ transition 26 
            currentDirection = requestedFloor > currentFloor;
            //#]
            moving_entDef();
            animInstance().notifyTransitionEnded("26");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void normalMode_entDef() {
            normalMode_enter();
        }
        
        //## statechart_method 
        public void awaitingForFloorSelection_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_11.awaitingForFloorSelection");
            state_11_subState = awaitingForFloorSelection;
            state_11_active = awaitingForFloorSelection;
            awaitingForFloorSelectionEnter();
        }
        
        //## statechart_method 
        public int awaitingForCall_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(CallLift.CallLift_CargoLiftSystem_id))
                {
                    res = awaitingForCallTakeCallLift();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_2_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void liftCalled_exit() {
            popNullConfig();
            liftCalledExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_2.liftCalled");
        }
        
        //## statechart_method 
        public void liftCalledExit() {
        }
        
        //## statechart_method 
        public void liftCalled_entDef() {
            liftCalled_enter();
        }
        
        //## statechart_method 
        public void state_2_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_2");
            state_2Enter();
        }
        
        //## statechart_method 
        public void doorsOpen_exit() {
            doorsOpenExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_3.doorsOpen");
        }
        
        //## statechart_method 
        public void doorsOpen_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_3.doorsOpen");
            state_3_subState = doorsOpen;
            state_3_active = doorsOpen;
            doorsOpenEnter();
        }
        
        //## statechart_method 
        public int idle_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(CallLift.CallLift_CargoLiftSystem_id))
                {
                    res = idleTakeCallLift();
                }
            else if(event.isTypeOf(doorClosed.doorClosed_CargoLiftSystem_id))
                {
                    res = idleTakedoorClosed();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void startedMovingExit() {
        }
        
        //## statechart_method 
        public void state_3_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_3");
            state_3Enter();
        }
        
        //## statechart_method 
        public int normalModeTakealarmTriggered() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("6");
            normalMode_exit();
            alarmMode_entDef();
            animInstance().notifyTransitionEnded("6");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void mode_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_4.mode");
            state_4_subState = mode;
            modeEnter();
        }
        
        //## statechart_method 
        public void activeLift_exit() {
            state_3_exit();
            state_4_exit();
            state_2_exit();
            state_11_exit();
            activeLiftExit();
            animInstance().notifyStateExited("ROOT.activeLift");
        }
        
        //## statechart_method 
        public void floorSelected_entDef() {
            floorSelected_enter();
        }
        
        //## statechart_method 
        public void awaitingTasksGeneratedExit() {
            //#[ state ROOT.activeLift.state_3.awaitingTasksGenerated.(Exit) 
            for(int a : itsScheduleApplication.getLiftCalls())
             System.out.println("zamowione pietra " + a);
            /*boolean liftCallsEmpty = itsScheduleApplication.ifLiftCallsEmpty();
            boolean selectedFloorsEmpty = itsScheduleApplication.getLiftCalls().isEmpty();
            System.out.println("Task queue empty: " + itsScheduleApplication.ifTaskQueueEmpty());
            System.out.println("Lift calls empty: " + liftCallsEmpty + " , selected floors empty " +selectedFloorsEmpty ); 
            
            if(!selectedFloorsEmpty) {
            requestedFloor = itsScheduleApplication.getRequestedFloorPoll();
            System.out.println("Lift is going to (floors selected)" + requestedFloor);
            }
            else if(!liftCallsEmpty)
            {
            requestedFloor = itsScheduleApplication.getLiftCallsPoll();
            System.out.println("Lift is going to (lift Calls)" + requestedFloor);
            }
            else
            itsScheduleApplication.setTaskQueue(true);*/
            
            //#]
        }
        
        //## statechart_method 
        public void awaitingTasksGenerated_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_3.awaitingTasksGenerated");
            pushNullConfig();
            state_3_subState = awaitingTasksGenerated;
            state_3_active = awaitingTasksGenerated;
            awaitingTasksGeneratedEnter();
        }
        
        //## statechart_method 
        public int idleTakeCallLift() {
            CallLift params = (CallLift) event;
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("2");
            idle_exit();
            awaitingTasksGenerated_entDef();
            animInstance().notifyTransitionEnded("2");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public int alarmMode_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(alarmFinished.alarmFinished_CargoLiftSystem_id))
                {
                    res = alarmModeTakealarmFinished();
                }
            else if(event.isTypeOf(inAlarmMode.inAlarmMode_CargoLiftSystem_id))
                {
                    res = alarmModeTakeinAlarmMode();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = mode_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void normalMode_exit() {
            normalModeExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_4.mode.normalMode");
        }
        
        //## statechart_method 
        public void modeEnter() {
        }
        
        //## statechart_method 
        public int state_4_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void state_4_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_4");
            state_4Enter();
        }
        
        //## statechart_method 
        public void state_4Enter() {
        }
        
        //## statechart_method 
        public void activeLift_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift");
            rootState_subState = activeLift;
            rootState_active = activeLift;
            activeLiftEnter();
        }
        
        //## statechart_method 
        public void rootStateExit() {
        }
        
        //## statechart_method 
        public void awaitingForCall_exit() {
            awaitingForCallExit();
            animInstance().notifyStateExited("ROOT.activeLift.state_2.awaitingForCall");
        }
        
        //## statechart_method 
        public void doorsOpenExit() {
        }
        
        //## statechart_method 
        public void idleExit() {
        }
        
        //## statechart_method 
        public void liftArrived_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_3.liftArrived");
            state_3_subState = liftArrived;
            state_3_active = liftArrived;
            liftArrivedEnter();
        }
        
        //## statechart_method 
        public int moving_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = movingTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void sensorDetectedNextFloorExit() {
        }
        
        //## statechart_method 
        public void awaitingForFloorSelection_entDef() {
            awaitingForFloorSelection_enter();
        }
        
        //## statechart_method 
        public int awaitingForCallTakeCallLift() {
            CallLift params = (CallLift) event;
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            animInstance().notifyTransitionStarted("12");
            awaitingForCall_exit();
            //#[ transition 12 
            if(!itsScheduleApplication.getLiftCalls().contains(params.floor))
            { itsScheduleApplication.addLiftCalls(params.floor);
              System.out.println("Lift called on floor " + params.floor);
            }
            //#]
            liftCalled_entDef();
            animInstance().notifyTransitionEnded("12");
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void awaitingForCall_entDef() {
            awaitingForCall_enter();
        }
        
        //## statechart_method 
        public void state_2EntDef() {
            animInstance().notifyTransitionStarted("11");
            awaitingForCall_entDef();
            animInstance().notifyTransitionEnded("11");
        }
        
        //## statechart_method 
        public void activated_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_3.activated");
            state_3_subState = activated;
            state_3_active = activated;
            activatedEnter();
        }
        
        //## statechart_method 
        public int awaitingTasksGenerated_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = awaitingTasksGeneratedTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_3_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void liftArrivedExit() {
        }
        
        //## statechart_method 
        public void liftStopping_enter() {
            animInstance().notifyStateEntered("ROOT.activeLift.state_3.liftStopping");
            pushNullConfig();
            state_3_subState = liftStopping;
            state_3_active = liftStopping;
            liftStoppingEnter();
        }
        
        //## statechart_method 
        public void state_3Enter() {
        }
        
        /**  methods added just for design level debugging instrumentation */
        public boolean startBehavior() {
            try {
              animInstance().notifyBehavioralMethodEntered("startBehavior",
                  new ArgData[] {
                   });
              return super.startBehavior();
            }
            finally {
              animInstance().notifyMethodExit();
            }
        }
        public int takeEvent(RiJEvent event) { 
            try { 
              //animInstance().notifyTakeEvent(new AnimEvent(event));
              animInstance().notifyBehavioralMethodEntered("takeEvent",
                  new ArgData[] { new ArgData(RiJEvent.class, "event", event.toString())
                   });
              return super.takeEvent(event); 
            }
            finally { 
              animInstance().notifyMethodExit();
            }
        }
        /**  see com.ibm.rational.rhapsody.animation.AnimatedReactive interface */
        public AnimInstance animInstance() { 
            return Lift.this.animInstance(); 
        }
        
    }
    //#[ ignore
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public AnimClass getAnimClass() { 
        return animClassLift; 
    }
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public Object getFieldValue(java.lang.reflect.Field f, Object userInstance) { 
         Object obj = null;
         try {
             obj = f.get(userInstance);
         } catch(Exception e) {
              System.err.println("Exception: getting Field value: " + e);
              e.printStackTrace();
         }
         return obj;
    }
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public AnimInstance animInstance() {
        if (animate == null) 
            animate = new Animate(); 
        return animate; 
    } 
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public void addAttributes(AnimAttributes msg) {
        
        msg.add("currentFloor", currentFloor);
        msg.add("currentDirection", currentDirection);
        msg.add("nextFloor", nextFloor);
        msg.add("stop", stop);
        msg.add("requestedFloor", requestedFloor);
        msg.add("floorsCount", floorsCount);
    }
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public void addRelations(AnimRelations msg) {
        
        msg.add("itsLights", true, true, itsLights);
        msg.add("itsEngine", false, true, itsEngine);
        msg.add("itsIndoorDisplay", true, true, itsIndoorDisplay);
        msg.add("itsScheduleApplication", true, true, itsScheduleApplication);
        msg.add("itsAlarm", false, true, itsAlarm);
        msg.add("itsController", false, true, itsController);
        msg.add("itsInnerDoor", true, true, itsInnerDoor);
        msg.add("itsOverloadDetector", true, true, itsOverloadDetector);
        msg.add("itsSmokeDetector", true, true, itsSmokeDetector);
        msg.add("itsLocationDetector", true, true, itsLocationDetector);
        msg.add("itsObstacleInDoorDetector", true, true, itsObstacleInDoorDetector);
        msg.add("itsAlarmBreakingDetector", true, true, itsAlarmBreakingDetector);
        msg.add("itsDoorsLock", true, false, itsDoorsLock);
        msg.add("itsOuterDoor", false, false, itsOuterDoor);
    }
    /** An inner class added as instrumentation for animation */
    public class Animate extends AnimInstance { 
        public  Animate() { 
            super(Lift.this); 
        } 
        public void addAttributes(AnimAttributes msg) {
            Lift.this.addAttributes(msg);
        }
        public void addRelations(AnimRelations msg) {
            Lift.this.addRelations(msg);
        }
        
        public void addStates(AnimStates msg) {
            if ((reactive != null) && (reactive.isTerminated() == false))
              reactive.rootState_add(msg);
        }
        
    } 
    //#]
    
}
/*********************************************************************
	File Path	: DefaultComponent/DefaultConfig/CargoLiftSystem/Lift.java
*********************************************************************/

